import { downloadFileFromBlobPart } from '@vben/utils'
import { requestClient } from '#/api/request'

// 获取出库列表 - outSelect索引页面
export function getOutSelectIndex(params: any) {
  return requestClient.get('/admin/sendRecord/outSelectIndex', params)
}

// 获取出库详情 (如需要)
export function getOutSelectInfo(params: any) {
  return requestClient.get('/admin/sendRecord/edit', params)
}

// 导出出库数据 - 使用与项目规则中的导出示例一致的方法
export async function exportOutSelectData(params: any) {
  const res = await requestClient.get('/admin/sendRecord/outSelectindex', params, {
    responseType: 'blob',
    responseReturn: 'raw',
  })

  const blob = new Blob([res.data], {
    type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  })
  downloadFileFromBlobPart({
    source: blob,
    fileName: '出库单明细.xlsx',
  })
}

// 获取物料类型列表
export function getMaterialCategoryList(params: any) {
  return requestClient.get('/admin/MaterialCategory/index', params)
}
